/**
 * Floor
 * @author yulipu
 */
function FloorJQ(id) {
	this.floorObj = jQuery('#'+id);
	this.floorALink = [];  // 链接  dom对象
	this.floorContent = [];  // 内容容器 dom对象
}
FloorJQ.prototype = {
	constructor : FloorJQ
	,processALink : function() {
		var len = this.floorALink.length;
		for(var i=0; i<len; i++) {
			this.floorALink[i].className = '';
		}
	}
	,hideContent : function() {
		var len = this.floorContent.length;
		for(var i=0; i<len; i++) {
			this.floorContent[i].style.display = 'none';
		}
	}
	,processContent : function() {
		// 关闭所有
		this.hideContent();
		// 找到当前是第几个 a 
		var len = this.floorALink.length;
		var idx = 0;
		for(var i=0; i<len; i++) {
			if("" != this.floorALink[i].className) {
				idx = i;
				break;
			}
		}
		this.floorContent[idx].style.display = 'block';
	}
	,start : function() {
		var _self = this;
		var len = _self.floorALink.length;
		var obj = null;
		for(var i=0; i<len; i++) {
			obj = _self.floorALink[i];
			obj.onclick = function() {
				// 先移除所有 a 的背景
				_self.processALink();
				this.className = 'active';
				
				// 内容处理
				_self.processContent();
			};
			obj = null;
		}
	}
	,init : function() {
		var _self = this;
		_self.floorObj.find('.y-floorTitletALink > a').each(function(i, obj){
			_self.floorALink.push(obj);
		});
		// 内容区
		_self.floorObj.find('.y-floorContent-padding').each(function(i, obj){
			_self.floorContent.push(obj);
		});
		
		// 确保数目一致
		if(_self.floorContent.length == _self.floorALink.length)
			_self.start();
	}
};